package com.zjl.filter;

import jakarta.servlet.*;

import java.io.IOException;

/**
 * @ClassName DemoFilter
 * @Description TODO
 * @Author ZJL
 * @Date 2023/11/2 0:56
 * @Version 1.0
 **/
//@WebFilter(urlPatterns = "/*")
public class DemoFilter  implements Filter {
    //初始化方法, 只调用一次
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("DemoFilter   放行前逻辑.....");

        //放行请求
        filterChain.doFilter(servletRequest,servletResponse);

        System.out.println("DemoFilter   放行后逻辑.....");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
